using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

namespace TVT.UI.Helpers
{
    public class StylesApplier
    {

        public void GridViewStyle(GridViewRow row)
        {
                      
            foreach (TableCell cell in row.Cells)
            {
                cell.Style.Add(HtmlTextWriterStyle.BorderStyle, BorderStyle.None.ToString());
               // cell.BorderWidth = 0;
              //  cell.Style.Add(HtmlTextWriterStyle.PaddingLeft, "2px");
               // cell.BorderColor = System.Drawing.Color.FromArgb(195, 225, 255);
             //   cell.BackColor = System.Drawing.Color.FromArgb(255, 253, 232);

                try
                {
                    decimal cellValue = Decimal.Parse(cell.Text, System.Globalization.NumberStyles.Any);
                    if (cell.Text.Contains("-"))
                    {
                        cell.ForeColor = Color.Red;
                    }
                }
                catch (Exception)
                {

                }
                
            }

        }


        public static void LabelStyle(Label lbl)
        {
           
            try
            {
                decimal value = Decimal.Parse(lbl.Text, System.Globalization.NumberStyles.Any);
                if (lbl.Text.Contains("-"))
                {
                    lbl.ForeColor = Color.Red;
                }
                else 
                {
                    lbl.ForeColor = Color.Empty;
                }
            }
            catch (Exception)
            {

            }

            

        }

        public static TableCell GetTableCellRowStyle()
        {
            TableCell cell = new TableCell();
            cell.BorderColor = Color.Black;
            cell.BorderStyle = BorderStyle.Solid;
            cell.BorderWidth = Unit.Pixel(1);
            cell.HorizontalAlign = HorizontalAlign.Center;

            return cell;
        }

        public static TableCell GetTableCellHeaderStyle()
        {
            TableCell cell = GetTableCellRowStyle();
            cell.Font.Bold = true;
            cell.ForeColor = Color.Black;
            cell.HorizontalAlign = HorizontalAlign.Center;

            return cell;
        }

        public static TableCell GetTableCellGroupStyle()
        {
            TableCell cell = GetTableCellHeaderStyle();
            cell.BackColor = Color.Gray;
            cell.HorizontalAlign = HorizontalAlign.Center;

            return cell;
        }
    }
}
